/*
 * Alvin Baldemeca
 * TCSS 305 - Spring 2012
 * Assignment 4 Power Paint
 */


package gui.actions.paint;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import view.container.TetrisPaintPanel;

/**
 * This class is an action that undo the last shape drawn in the PowerPaint drawing panel.
 * @author Alvin Baldemeca
 * @version 5/17/2012
 *
 */
@SuppressWarnings("serial")
public class UndoAction extends AbstractAction
{
  /**
   * The panel to perform the action to.
   */
  private final TetrisPaintPanel my_panel;
  
  /**
   * Creats an Undo action to undo the last shape drawn on the panel.
   * @param the_panel PowerPaintDrawingPanel to undo the shape last drawn.
   */
  public UndoAction(final TetrisPaintPanel the_panel)
  {
    super("Undo");
    putValue(Action.MNEMONIC_KEY, KeyEvent.VK_U);
    putValue(Action.SELECTED_KEY, true);
    my_panel = the_panel;
  }

  @Override
  public void actionPerformed(final ActionEvent the_event)
  {
    my_panel.undo(); 
  }

}


